package com.demos.diveinspring.bootstrap;

import com.demos.diveinspring.service.CalculateService;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan(basePackages = "com.demos.diveinspring.service")
public class CalculateServiceBootstrap {
    public static void main(String[] args) {
        // 必须指定.profiles("Java7") 否则会报错的，因为这个条件的加载，不指定容器不知道加载装配谁
        ConfigurableApplicationContext context = new SpringApplicationBuilder(CalculateServiceBootstrap.class)
                .web(WebApplicationType.NONE)
                .profiles("Java7")
                .run(args);
        CalculateService contextBean = context.getBean(CalculateService.class);
        System.out.println("CalculateService: ***** SUM： " + contextBean.sum(1,2,3));
        context.close();
    }
}
